﻿
@{
    ViewBag.Title = "ExpertsAdd";
    Layout = "~/Areas/AdminInfo/Views/Shared/_LayoutPage1.cshtml";
}



@model Gtkj.CMS.Model.Experts
<div class="container-fluid larry-wrapper">
    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-12">
            <section class="panel panel-padding">

                <form id="form1" class="layui-form layui-form-pane" data-render="true">
                    <div class="layui-form-item">
                        <label class="layui-form-label">姓名</label>
                        <div class="layui-input-block">
                            <input type="text" name="Name" value="@(Model==null?"": Model.Name)" required jq-verify="required" jq-error="请输入姓名" placeholder="请输入姓名" autocomplete="off" class="layui-input ">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">职位</label>
                        <div class="layui-input-block">
                            <input type="text" name="JobDescription" value="@(Model==null?"": Model.JobDescription)" required jq-verify="required" jq-error="请输入职位" placeholder="请输入职位" autocomplete="off" class="layui-input ">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">简介</label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入内容" name="Introduce" class="layui-textarea">@(Model == null ? "" : Model.Introduce)</textarea>
                            
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">上传图片</label>
                        <div class="layui-input-inline">
                            <input type="file" name="Logo" class="layui-upload-file">
                            <input type="hidden" name="Image" id="imgsrc" value="@(Model == null ? "" : Model.Portrait)">
                            <p id="img-error" class="error">
                                @{
                                    if (Model != null)
                                    {
                                        if (Model.Portrait != null || Model.Portrait != "")
                                        {
                                            <img src="@Model.Portrait" alt="..." class="img-thumbnail">
                                        }
                                    }
                                }
                            </p>

                        </div>
                    </div>

                    <div class="layui-form-item ">
                        <label class="layui-form-label">排名</label>
                        <div class="layui-input-inline">
                            <input type="text" name="Sorting" onkeydown=" if (!(event.keyCode == 46) && !(event.keyCode == 8) && !(event.keyCode == 37) && !(event.keyCode == 39))
     if (!((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105)))
         event.returnValue = false;" required jq-verify="number" value="@(Model == null ? 0 : Model.Sorting == null ? 0 : Model.Sorting)" jq-error="排名必须为数字" placeholder="请输入排名" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
                            @if (Model == null)
                            {
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            }
                        </div>
                    </div>
                    <input type="hidden" name="ID" value="@(Model==null?"":Model.ID.ToString())" />
                </form>
            </section>
        </div>
    </div>
</div>
<script>
    var $;
    //var $Type = $("Type");
    layui.use(['form', 'upload', 'jqform'], function () {
        var editIndex;
        $ = layui.jquery,
            jqform = layui.jqform,
         form = layui.form(), layedit = layui.layedit;
        form.render(); //这个很重要
        layui.upload({
            url: '/Upload/UploadPic' //上传接口file1
         , success: function (res) { //上传成功后的回调
             console.log(res);
             $('#img-error').html("");
             $('#imgsrc').val(res.data);
             $('#img-error').append('<img src="' + res.data + '" alt="..." class="img-thumbnail">');
         }
        });

        form.on('submit(sub)', function (data) {
          
            $.post('/AdminInfo/AdminExperts/AddExpertsInfo', data.field, function (r) {
                if (r.status == 200) {
                    layer.msg(r.message, {
                        icon: 6,
                        time: 2000,
                    });
                } else {
                    layer.msg(r.message, { icon: 2 });
                }
            });
            return false;
        });
    });
</script>
